package com.fate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fate.domain.SysLog;
import com.fate.mapper.SysLogMapper;
import com.fate.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {

    @Autowired
    private SysLogMapper sysLogMapper;

    @Override
    public Page<SysLog> findSysLogPage(Page<SysLog> page, SysLog sysLog) {
       return (Page<SysLog>) sysLogMapper.selectPage(page,new LambdaQueryWrapper<SysLog>()
               .like(StringUtils.hasText(sysLog.getUsername()),SysLog::getUsername,sysLog.getUsername())
               .like(StringUtils.hasText(sysLog.getOperation()),SysLog::getOperation,sysLog.getOperation())
               .orderByDesc(SysLog::getCreateDate));
    }
}
